import Vue from 'vue'
import Router from 'vue-router'

//获取原型对象上的push函数
const originalPush = Router.prototype.push
//修改原型对象中的push方法
Router.prototype.push = function push (location) {
    return originalPush.call(this, location).catch(err => err)
}

Vue.use(Router)

//路由懒加载：按需加载、在使用的时候加载
const UserActivity = () => import('../components/user/activity-recent/UserActivity');
const PersonCenter = () => import('../components/user/PersonCenter');
const UserRecent = () => import('../components/user/activity-recent/UserRecent');
const UserServer = () => import('../components/user/UserServer');
const UserTransaction = () => import('../components/user/UserTransaction');



const MerchantsOrder = () => import('../components/merchants/MerchantsOrder');
const MerchantsServer = () => import('../components/merchants/MerchantsServer');

const PropertySuggest = () => import('../components/property/PropertySuggest');
const PropertyManagement = () => import('../components/property/PropertyManagement');

const PlatformLogView = () => import('../components/platform/PlatformLogView');
const PlatformManagement = () => import('../components/platform/PlatformManagement');

const UserDetail = () => import('../components/user/detail/userdetail');

const Welcome = () => import('../components/Welcome');

export default new Router({
    routes: [
        // 用户组件
        {
            path: '/userActivity',
            component: UserActivity
        },
        {
            path: '/personCenter',
            component: PersonCenter
        },
        {
            path: '/userRecent',
            component: UserRecent
        },
        {
            path: '/userServer',
            component: UserServer
        },
        {
            path: '/userTransaction',
            component: UserTransaction
        },
        //商家组件
        {
            path: '/merchantsOrder',
            component: MerchantsOrder
        },
        {
            path: '/merchantsServer',
            component: MerchantsServer
        },
        //物业组件
        {
            path: '/propertyManagement',
            component: PropertyManagement
        },
        {
            path: '/propertySuggest',
            component: PropertySuggest
        },
        //平台组件
        {
            path: '/platformLogView',
            component: PlatformLogView
        },
        {
            path: '/platformManagement',
            component: PlatformManagement
        }, 
        {
            path: '/userdetail',
            component: UserDetail
        },
        {
            path: '/welcome',
            component: Welcome
        },
    ],
    mode: 'history'
})
